package com.xiaoxu.privatechat.dao.admin;

import com.xiaoxu.privatechat.entity.admin.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * @description 用户数据库处理层
 * @author xiaoxu
 * @date 2023/2/13
 */
@Repository
public interface UserDao extends JpaRepository<User, Long>{
	
	/**
	 * @description 按照用户名查找用户信息
	 * @param username 用户名
	 * @return User
	 */
	 User findByUsername(String username);

	/**
	 * @description 根据用户id查询
	 * @param id 用户id
	 * @return User
	 */
	@Query("select u from User u where u.id = :id")
	 User find(@Param("id")Long id);
	
}
